using System;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System.IO;
using SharpWind.Helpers;

namespace SharpWind.Resources
{
	public class Font : Resource
	{
		private SpriteFont xnaFont = null;

		private string name = string.Empty;

		public Font( string name )
		{
			if( string.IsNullOrEmpty( name ) )
			{
				throw new ArgumentNullException( "name" );
			}

			this.name = Path.GetFileNameWithoutExtension( name );
		}

		internal override void LoadContent( ContentManager contentManager )
		{
			this.xnaFont = contentManager.Load<SpriteFont>( Path.Combine( Directories.Fonts, this.name ) );
		}

		public string Name
		{
			get
			{
				return this.name;
			}
		}

		internal SpriteFont XnaFont
		{
			get
			{
				return this.xnaFont;
			}
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				this.xnaFont = null;
			}
		}

		public static bool operator ==( Font left, Font right )
		{
			return left.Name == right.Name;
		}

		public static bool operator !=( Font left, Font right )
		{
			return left.Name != right.Name;
		}
	}
}
